package core;

import java.awt.geom.Rectangle2D;
import java.util.StringTokenizer;

/**
 * Base class for queries Defines what queries are like
 * 
 * @author Xiaohui
 * 
 */
public class QueryParser {
	int op;
	int qid;
	// double[] qx, qy;
	private double qx1, qy1, qx2, qy2;
	double startTime, endTime;

	public QueryParser(String queryStr) {
		StringTokenizer st = new StringTokenizer(queryStr);
		op = Integer.parseInt(st.nextToken());
		qid = Integer.parseInt(st.nextToken());
		qx1 = Double.parseDouble(st.nextToken());
		qy1 = Double.parseDouble(st.nextToken());
		qx2 = Double.parseDouble(st.nextToken());
		qy2 = Double.parseDouble(st.nextToken());
		startTime = Double.parseDouble(st.nextToken());
		endTime = Double.parseDouble(st.nextToken());
	}

	public int getOp() {
		return op;
	}

	public void setOp(int op) {
		this.op = op;
	}

	public long getQid() {
		return qid;
	}

	public void setQid(int qid) {
		this.qid = qid;
	}

	public double getQx1() {
		return qx1;
	}

	public void setQx1(double qx1) {
		this.qx1 = qx1;
	}

	public double getQy1() {
		return qy1;
	}

	public void setQy1(double qy1) {
		this.qy1 = qy1;
	}

	public double getQx2() {
		return qx2;
	}

	public void setQx2(double qx2) {
		this.qx2 = qx2;
	}

	public double getQy2() {
		return qy2;
	}

	public void setQy2(double qy2) {
		this.qy2 = qy2;
	}

	public double getStartTime() {
		return startTime;
	}

	public void setStartTime(double startTime) {
		this.startTime = startTime;
	}

	public double getEndTime() {
		return endTime;
	}

	public void setEndTime(double endTime) {
		this.endTime = endTime;
	}

	public Rectangle2D.Double getQueryRectangle() {
		return new Rectangle2D.Double(getQx1(), getQy1(), getQx2() - getQx1(),
				getQy2() - getQy1());
	}
}
